package com.job2e.service;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.job2e.common.Security;
import com.job2e.dao.HrDao;
import com.job2e.dao.UserDao;
import com.job2e.model.Hr;
import com.job2e.model.User;

@Service
public class HrService {
	@Autowired
	private HrDao dao = null;
	
	public Hr login(String email, String password) {
		Hr u = dao.findByEmail(email);
		if (u == null)
			return null;
		if (!u.getPassword().equals(Security.getMD5(password)))
			return null;
		return u;
	}

	public void save(Hr hr) {
		hr.setPassword(Security.getMD5(hr.getPassword()));
		hr.setState((short) 0);
		hr.setCreateTime(new Date());
		
		dao.save(hr);
	}

}
